import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import axios from 'axios'

export const useCounterStore = defineStore('counter', () => {
    const count = ref(0)
    function increment() {
        count.value++
    }

    const doubleCount = computed(() => count.value * 2)
    const list = ref([])
    const getList = async () => {
        const res = await axios.get("http://geek.itheima.net/v1_0/channels")
        list.value = res.data.data.channels
    }

    return {
        count,
        increment,
        doubleCount,
        getList,
        list
    }
})